package org.nowcoder.huawei.c200;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 6: 数据单元的变量替换
 */


public class HC006 {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] cells = br.readLine().split(",");
            solve(cells);
        } catch (Exception ignore) {
        }
    }

    public static void solve(String[] cells) {
        Map<String, String> ref = new HashMap<>();

        //1. 将行转为map
        for (int i = 0; i < cells.length; i++) {
            ref.put(String.valueOf((char) ('A' + i)), cells[i]);
        }

        String refPattern = "<([A-Z])>";
        Pattern pattern = Pattern.compile(refPattern);
        boolean flag = true;
        while (flag) {
            flag = false;
            for (String cell : ref.keySet()) {
                Matcher matcher = pattern.matcher(ref.get(cell));
                if (matcher.find()) {
                    String key = matcher.group(1);
                    ref.put(cell, ref.get(cell).replace(matcher.group(0), ref.get(key)));
                    flag = true;
                }
            }
        }
        System.out.println(String.join(",", ref.values()));
    }

    public static int binarySearch0(int[] arr, int target) {
        int left = 0, right = arr.length - 1;
        while (left <= right) {
            //int mid = (left + right) / 2;
            int mid = left + (right - left) / 2;
            if (arr[mid] < target) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return left;
    }

    public static int binarySearch1(int[] arr, int target) {
        int left = 0, right = arr.length;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (arr[mid] < target) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        return left;
    }
}
